import debug from 'debug';

const APP_NAME = 'LD';

export class Logger {
	_debug: debug.Debugger;
	_warn: debug.Debugger;
	_error: debug.Debugger;

	constructor(prefix?: string) {
		localStorage.debug = "*"
		if (prefix) {
			this._debug = debug(`[${APP_NAME}:🐛]->${prefix}`);
			this._warn = debug(`[${APP_NAME}:⚠️]->${prefix}`);
			this._error = debug(`[${APP_NAME}:❌]->${prefix}`);
		} else {
			this._debug = debug(APP_NAME);
			this._warn = debug(`${APP_NAME}:⚠️ -> `);
			this._error = debug(`${APP_NAME}:❌ -> `);
		}

		/* eslint-disable no-console */
		this._debug.log = console.info.bind(console);
		this._warn.log = console.warn.bind(console);
		this._error.log = console.error.bind(console);
		/* eslint-enable no-console */
	}

	get debug() {
		return this._debug;
	}

	get warn() {
		return this._warn;
	}

	get error() {
		return this._error;
	}
}
